﻿// <copyright file="ArmiesPlayer.cs" company="Gravity Age Studios">
// Code released under the MIT license (see License.txt).
// </copyright>
// <author>Vicente Cartas Espinel</author>
// <email>vicente.cartas@gmail.com</email>
namespace LightSwitchApplication
{
    using Microsoft.LightSwitch.Presentation.Extensions;

    public partial class MercenariesPlayer
    {
        #region View Army

        partial void ViewArmyDetails_CanExecute(ref bool result)
        {
            result = this.Collection.SelectedItem != null &&
                    (this.Collection.SelectedItem.HasPublicInformation == true ||
                     this.LandUnits.Count > 0 ||
                     this.SeaUnits.Count > 0);
        }

        partial void ViewArmyDetails_Execute()
        {
            this.FindControl("ModalWindowArmy").DisplayName = string.Format("View {0} details", this.Collection.SelectedItem.Name);
            this.OpenModalWindow("ModalWindowArmy");
        }

        partial void SubmitModalWindowArmy_Execute()
        {
            this.CloseModalWindow("ModalWindowArmy");
        }

        #endregion

        #region View LandUnit

        partial void ViewLandUnitDetails_CanExecute(ref bool result)
        {
            result = this.LandUnits.SelectedItem != null &&
                     this.LandUnits.SelectedItem.HasPublicInformation == true;
        }

        partial void ViewLandUnitDetails_Execute()
        {
            this.FindControl("ModalWindowLandUnit").DisplayName = string.Format("View {0} details", this.LandUnits.SelectedItem.Name);
            this.OpenModalWindow("ModalWindowLandUnit");
        }

        partial void SubmitModalWindowLandUnit_Execute()
        {
            this.CloseModalWindow("ModalWindowLandUnit");
        }

        #endregion

        #region View SeaUnit

        partial void ViewSeaUnitDetails_CanExecute(ref bool result)
        {
            result = this.SeaUnits.SelectedItem != null &&
                     this.SeaUnits.SelectedItem.HasPublicInformation == true;
        }

        partial void ViewSeaUnitDetails_Execute()
        {
            this.FindControl("ModalWindowSeaUnit").DisplayName = string.Format("View {0} details", this.SeaUnits.SelectedItem.Name);
            this.OpenModalWindow("ModalWindowSeaUnit");
        }

        partial void SubmitModalWindowSeaUnit_Execute()
        {
            this.CloseModalWindow("ModalWindowSeaUnit");
        }

        #endregion
    }
}
